package com.yy.permissions_general.module.system.menu.vo;

import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName MenuVo
 * @Description: TODO 菜单vo
 * @Author YangYI
 * @Date 2021/9/29
 * @Version V1.0
 **/
@Data
public class MenuVo implements Serializable  {
    private static final long serialVersionUID = 1L;
    private Integer id;
    private Integer parentId;
    private String title;
    private String href;
    private String icon;
    private String target;
    private Integer type;
    private String authCode;
    private List<MenuVo> child;

    /**
     * 递归
     * @param id 当前菜单ID
     * @param list 菜单列表
     * @return
     */
    public static List<MenuVo> menuVoUtil(Integer id,List<MenuVo> list){
        List<MenuVo> trees = new ArrayList();
        for (MenuVo menuVo : list) {
            if (menuVo.getParentId()== id){
                menuVo.setChild(menuVoUtil(menuVo.getId(),list));
                trees.add(menuVo);
            }
        }
        return trees;
    }
}
